const express = require('express')
const app = new express(); // 初始化
const userRouter = require('./router/userRouter')
const stockRouter = require('./router/stockRouter')
const dbUtile = require('./dao/DBUtil')
const roleRouter = require('./router/roleRouter')

/*  导入 cors ---》跨域  */
const cors = require('cors')

app.use(cors())
app.use(express.urlencoded({extended:false}))// post请求支持
app.use('/user',userRouter); // \user\login  \user\list
app.use('/stock',stockRouter); // \stock\list
app.use('/role',roleRouter)    // \role\list

dbUtile.init()

const server = app.listen(3000, 'localhost',(req,res)=>{

    let host= server.address().address;
    let port = server.address().port;

    console.log("This is http://%s:%s",host,port)

})
